layui.use(['jquery','layer','table'], function() {
	var $ = layui.$,
		layer = layui.layer,
		table = layui.table;
	var send_info = function(string_uri, json_data, fun_callback) {
		layer.load(2);
		$.ajax({
			type: "post",
			url: string_uri,
			async: true,
			data: json_data,
			dataType: 'json',
			success: function(data) {
				layer.closeAll('loading');
				if (data['code'] == -101) {
					location.href = 'login.html';
					return false;
				} else if (data['code'] == -200) {
					layer.msg(data['msg'], {
						icon: 2,
						anim: 6
					});
					return false;
				} else if (data['code'] == 0 && data['msg'] == '参数错误') {
					layer.msg('参数错误', {
						icon: 2,
						anim: 6
					});
				} else {
					return fun_callback(data);
				}
			},
			error: function(xhr, type, errorThrown) {
				layer.msg('请求失败，访问地址：' + string_uri, {
					icon: 2,
					anim: 6
				});
				layer.closeAll('loading');
			}
		});
	};
	$('#close_page').on('click',function(){
		parent.layer.closeAll();
	})
	$('#refuse_order').on('click',function(){
		layer.confirm('确认拒绝该报价单吗？',{icon:3},function(e){
			let post_json = {
				offer_id:offer_id,
				audit_state:3
			};
			send_info(save_url,post_json,function(data){
				parent.layer.closeAll();
				parent.layui.table.reload('offer_list');
				parent.layer.msg('操作成功');
			})
		});
	})
	$('#confirm_order').on('click',function(){
		layer.confirm('确认通过报价单之后将推送价格到军采系统，确定推送吗？',{icon:3},function(e){
			let post_json = {
				offer_id:offer_id,
				audit_state:1
			};
			send_info(save_url,post_json,function(data){
				parent.layer.closeAll();
				parent.layui.table.reload('offer_list');
				parent.layer.msg('操作成功');
			})
		});
	})
})